package com.bwie.controller;

import com.bwie.pojo.Prod;
import com.bwie.service.ProdService;
import com.bwie.utils.R;
import com.bwie.vo.PageInfoVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * description:
 *
 * @Author chentong
 * @Create 2025/4/28 10:03
 * @Version 1.0
 */
@RestController
@RequestMapping("/prod/prod")
@Api(tags = "商品管理")
public class ProdController {

    @Autowired
    ProdService prodService;

    /**商品列表分页查询
     * @param pageInfoVo
     * @return
     */
    @ApiOperation(value = "商品列表分页查询")
    @PostMapping("/prodList")
    public R prodList(@RequestBody PageInfoVo pageInfoVo){
        return prodService.prodList(pageInfoVo);
    }

    /**
     * 商品添加
     * @param prod
     * @return
     */
    @ApiOperation(value = "商品添加")
    @PostMapping("/addProd")
    public R addProd(@RequestBody Prod prod){
        return prodService.addProd(prod);
    }

    /**
     * 根据id查询字典表信息
     * @param typeId
     * @return
     */
    @ApiOperation(value = "根据id查询字典表信息")
    @PostMapping("/dictList/{typeId}")
    public R dictList(@PathVariable(name = "typeId")Integer typeId){
        return prodService.dictList(typeId);
    }

    /**
     * 删除商品信息
     * @param prodId
     * @return
     */
    @ApiOperation(value = "删除商品信息")
    @PostMapping("/deleteProd/{prodId}")
    public R deleteProd(@PathVariable(name = "prodId")Integer prodId){
        return prodService.deleteProd(prodId);
    }

    @ApiOperation(value = "修改商品信息")
    @PostMapping("/updateProd")
    public R updateProd(@RequestBody Prod prod){
        return prodService.updateProd(prod);
    }
}
